package stu.aistar.mapper;

import org.apache.ibatis.annotations.*;
import stu.aistar.model.pojo.Ciname;

import java.util.List;

@Mapper
public interface CinameMapper {

    @Select("<script>"
            + "select * from ciname"
            + " <where>"
            + "   <if test='name != null' > "
            + "	    and name like '%${value}%'"
            + "	  </if>"
            + "</where>"
            + "</script>")
    List<Ciname> findAllByName(String name);

    @Select("select *from ciname")
    List<Ciname> findAll();

    @Select("select count(*) from ciname")
    Integer getTotal();


    @Insert("insert into ciname(name,province,city,area) values(#{name},#{province},#{city},#{area})")
    Integer insertCiname(Ciname ciname);

    @Delete("delete from ciname where id = #{id}")
    Integer delCinameById(@Param("id") Integer id);


    @Select("select *from ciname where id = #{id}")
    Ciname findById(Integer id);

    @Update("update ciname set name = #{name},province = #{province},area = #{area} where id = #{id}")
    Integer editCiname(Ciname ciname);
}
